<!--参与者维护页面-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
    ></ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="150" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('detials', scope.row);
                  },
                },
                {
                  label: '维护',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('maintain', scope.row);
                  },
                },
                {
                  label: '删除',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('delete', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <!-- 明细弹出框 -->
    <details-dialog
      ref="detailsDialog"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></details-dialog>
    <!-- 维护弹出框 -->
    <maintain-dialog
      ref="maintainDialog"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></maintain-dialog>
  </div>
</template>
<script>
import {
  apiUrlConfig,
  detailsQuery,
  delConfigInfo,
} from "@/api/cnaps/ccms/bankCodeMng/participant_maintenance_query.js";
import DetailsDialog from "./components/ParticipantQueryDetails";
import MaintainDialog from "./components/ParticipantQueryMaintain";
import { listPageMixin } from "@/libs/listPageMixin";

export default {
  name: "ParticipantMaintenanceQuery",
  mixins: [listPageMixin],
  components: {
    DetailsDialog,
    MaintainDialog,
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: ["CNAPS_FLAG_BANK", "PT_TYPE", "CNAPS_FLAG_BANK", "JOIN_SYSTEM"],
      //  明细弹框数据
      // form表单字段
      formData: {},
      showSearch: true,
      // 查询参数
      queryParams: {
        lglCcpc: "",
        category: "",
        lglCtCode: "",
        bankCode: "",
        bankName: "",
      },
      formOptions: [],
      opButtonList: () => {
        return [];
      },
      tableBindColumns: [
        { label: `行号`, prop: "bankCode", align: "center" },
        {
          label: `一二代标志`,
          prop: "cnapsFlag",
          dictCode: "CNAPS_FLAG_BANK",
          align: "center",
        },
        {
          label: `参与机构全称`,
          prop: "orgFullName",
          width: "230",
          align: "center",
        },
        {
          label: `所属直参行号`,
          prop: "drctBankCode",
          align: "center",
        },
        {
          label: `所属CCPC`,
          prop: "lglCcpc",
          align: "center",
        },
        {
          label: `行别代码`,
          prop: "category",
          align: "center",
        },
        {
          label: `所在城市代码`,
          prop: "lglCtCode",
          align: "center",
        },
        {
          label: `加入业务系统标识`,
          prop: "joinBizFlagDesc",
          width: "200",
          align: "center",
        },
      ],
    };
  },
  mounted() {
    this.formOptions = [
      {
        type: "input",
        prop: "lglCcpc",
        defaultAttr: {
          label: "所属CCPC",
          placeholder: "请输入所属CCPC",
        },
      },
      {
        type: "input",
        prop: "category",
        defaultAttr: {
          label: "行别代码",
          placeholder: "请输入行别代码",
        },
      },
      {
        type: "input",
        prop: "lglCtCode",
        defaultAttr: {
          label: "所在城市代码",
          placeholder: "请输入所在城市代码",
        },
      },
      {
        type: "input",
        prop: "bankCode",
        defaultAttr: {
          label: "行号",
          placeholder: "请输入行号",
        },
      },
      {
        type: "input",
        prop: "bankName",
        defaultAttr: {
          label: "参与机构全称",
          placeholder: "请输入参与机构全称",
        },
      },
    ];
  },
  methods: {
    editComplete(state) {
      if (state == true) {
        this.$refs.dataTable.doQuery();
      }
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "detials":
          // 明细信息
          detailsQuery(row).then((res) => {
            this.formData = _.clone(res.result);
            this.formData.joinBizFlagDesc = row.joinBizFlagDesc;
            this.$refs.detailsDialog.show();
          });
          break;
        case "maintain":
          // 明细信息
          detailsQuery(row).then((res) => {
            this.formData = res.result;
            this.formData.joinBizFlagDesc = row.joinBizFlagDesc;
            this.$refs.maintainDialog.show();
          });
          break;
        case "delete":
          const id = row.id || this.ids.join(",");
          this.$confirm(`确定删除该条参与者维护信息吗？`, "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(function () {
              return delConfigInfo({ bankCode: row.bankCode });
            })
            .then(() => {
              this.doQuery();
              this.msgSuccess("删除成功");
            })
            .catch((action) => {});
          break;
      }
    },
  },
};
</script>
